package com.lzw.mapper.supplier;

import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.Map;

@Mapper
public interface SupplierLoginMapper {

    @Select("SELECT supplier_id FROM pharmacymanagement.suppliers WHERE username = #{username} AND password = #{password}")
    Integer checkCredentials(@Param("username") String username, @Param("password") String password);

    @Select("SELECT supplier_id, company_name, name, phone, email, username, contact_person FROM pharmacymanagement.suppliers WHERE username = #{username} AND password = #{password}")
    Map<String, Object> getSupplier(@Param("username") String username, @Param("password") String password);

    @Select("SELECT supplier_id, company_name, password, username, email, phone, contact_person, name FROM pharmacymanagement.suppliers WHERE supplier_id = #{supplierId}")
    Map<String, Object> getSupplierById(Integer supplierId);

    @Update("UPDATE pharmacymanagement.suppliers SET name = #{name}, phone = #{phone}, email = #{email} WHERE supplier_id = #{supplierId}")
    boolean updateSupplier(@Param("supplierId") Integer supplierId, @Param("name") String name,
                           @Param("phone") String phone, @Param("email") String email);
}
